package com.wxzl.community.common.utils

import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
import com.wxzl.community.common.base.BaseApp

/**
 * @Author: LiaoZhongKai
 * @Date: 2021/5/14 18:28
 * @Description: 键盘工具
 */
object KeyboardUtil {

    fun showSoftInput(et: EditText){
        et.requestFocus()
        val imm = BaseApp.instance.applicationContext.getSystemService(AppCompatActivity.INPUT_METHOD_SERVICE) as InputMethodManager?
        imm?.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT)
    }

    fun hideSoftInput(et: EditText){
        et.clearFocus()
        val imm = BaseApp.instance.applicationContext.getSystemService(AppCompatActivity.INPUT_METHOD_SERVICE) as InputMethodManager?
        imm?.showSoftInput(et, InputMethodManager.HIDE_NOT_ALWAYS)
    }
}